package org.spring.bean.factory.support;

import lombok.Data;
import org.spring.bean.MutablePropertyValues;
import org.spring.bean.factory.config.BeanDefinition;
import org.tool.TipException;

/**
 * 具体的、成熟的 {@link BeanDefinition} 类的基类，分解出 {@link GenericBeanDefinition}、
 * {@link RootBeanDefinition} 和 {@link ChildBeanDefinition} 的公共属性。
 * <p>
 * autowire 常量与 {@link org.springframework.beans.factory.config.AutowireCapableBeanFactory} 接口中定义的常量相匹配。
 *
 * @author 李坤
 * @date 2022/4/20 17:46
 */
@Data
public abstract class AbstractBeanDefinition implements BeanDefinition {

    protected Class<?> beanClass;

    protected String beanClassName;

    private MutablePropertyValues propertyValues;

    public void setBeanClassName(String beanClassName) {
        this.beanClassName = beanClassName;
        try {
            this.beanClass = Class.forName(beanClassName);
        } catch (ClassNotFoundException exception) {
            throw new TipException("无法加载类：" + beanClassName);
        }
    }
}
